﻿@{
    ViewBag.Title = "FichasPacientes";
}

@section scripts{
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    

    <script type="text/javascript" language="javascript">
        $(function () {
            $('a[href$="Create"]').button().css('margin-bottom', '10px');

            function getCliente(id) {
                $.ajax({
                    type: "GET",
                    url: '@Url.Action("DatosFicha", "Pacientes")/?id=' + id,
                    success: function (data) {
                        $("#DatosCliente").html("");
                        $("#DatosCliente").html(data);
                    }
                });
            }

            $("#AutoComplete").autocomplete({
                source: '@(Url.Action("AutocompleteFichasUsuario"))',
                minLength: 3,
                select: function (event, ui) {
                    getCliente(ui.item.id);
                }
            });
        });
    </script>
}

<h2>Fichas Pacientes</h2>
<div>
    Nombre Paciente:
    @Html.TextBox("autocompletar", "", new { @id = "AutoComplete" })
</div>
@Ajax.ActionLink("Ingresar Paciente Nuevo",
                "DatosFicha",
                new { @id = -1 },
                new AjaxOptions
                    {
                        UpdateTargetId = "DatosCliente",
                        InsertionMode = InsertionMode.Replace,
                        HttpMethod = "GET"
                    }
                )


<div id="DatosCliente" style="width:100%; margin-left:auto; margin-right:auto;">
   @* @Html.Action("DatosFicha", "Pacientes", new { @id = -1 })*@
</div>